package org.xinjiang.data.migration.flush.convert;

import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.xinjiang.data.migration.flush.enums.*;
import org.xinjiang.data.migration.flush.utils.DefaultUtils;
import org.xinjiang.data.migration.hainan.entity.MstCommunityVolunteer;

import java.util.ArrayList;
import java.util.Collection;

/**
 * 志愿者
 */
@Component
public class VolunteerConvert extends BaseConvert<org.xinjiang.data.migration.xinjiang.entity.SqjzZyzgl, MstCommunityVolunteer> {

    @Override
    public MstCommunityVolunteer convert(org.xinjiang.data.migration.xinjiang.entity.SqjzZyzgl gzry) {
        MstCommunityVolunteer volunteer = new MstCommunityVolunteer();
        volunteer.setSourceId(gzry.getId());
//        volunteer.setRybm()//的需要生成
        volunteer.setXm(DefaultUtils.getName(gzry.getXingming()));
//        volunteer.setYwm()//没有
        volunteer.setXb(String.valueOf(SexEnum.sex(gzry.getXingbie()).getId().intValue()));
        volunteer.setCsrq(DefaultUtils.getDefCsrq(gzry.getChushengnianyue()));
        volunteer.setSfzh(DefaultUtils.getDefSfzh(gzry.getShenfenzhenghao()));
        volunteer.setZzmm(PoliticalOutlookEnum.toCode(gzry.getZhengzhimianmao()).getTargetCode());
//        volunteer.setZp()没有
        volunteer.setXl(EducationalLevelEnum.toCode(gzry.getXueli()).getTargetCode());
        volunteer.setZgxw(AcademicDegreeEnum.toCode(gzry.getZuigaoxuewei()).getTargetCode());
        volunteer.setZy(SpecialityEnum.toCode(gzry.getZhiye()).getTargetCode());
        volunteer.setSsjg(gzry.getLuruJigou());
//        volunteer.setJzjgbm();没有
        volunteer.setGzdw(gzry.getGongzuodanwei());
        volunteer.setSj(DefaultUtils.getPhone(gzry.getShouji()));
        volunteer.setLxdh(gzry.getLianxidianhua());
        volunteer.setJtzz(DefaultUtils.getDefJtzz(gzry.getLianxidizhi()));
        volunteer.setSfzz("1".equals(gzry.getShifouzaizhi()) ? "1" : "0");
        //更新人，更新时间，都没有
        volunteer.setCreateBy(gzry.getLuruId());
        volunteer.setCreateTime(gzry.getLts());
        return volunteer;
    }

    @Override
    public Collection<MstCommunityVolunteer> converts(Collection<org.xinjiang.data.migration.xinjiang.entity.SqjzZyzgl> ss) {
        Collection<MstCommunityVolunteer> collection = new ArrayList<>();
        if (CollectionUtils.isEmpty(ss)) {
            return collection;
        }
        for (org.xinjiang.data.migration.xinjiang.entity.SqjzZyzgl s : ss) {
            collection.add(convert(s));
        }
        return collection;
    }
}
